package main

import "math"

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

/**
搜索二叉树的左节点都比他小，右节点都比他大，

中序遍历
*/

//
//  isValidBST
//  @Description: 验证一棵树是否是搜索二叉树
//  @param root: 二叉树的根节点
//  @return bool:
//
func isValidBST(root *TreeNode) bool {
	var helper = func(node *TreeNode, lower, upper int) bool {
		return false
	}
	helper = func(node *TreeNode, lower, upper int) bool {
		if node == nil {
			return true
		}
		if node.Val <= lower || node.Val >= upper {
			return false
		}
		return helper(node.Left, lower, node.Val) && helper(node.Right, node.Val, upper)
	}
	return helper(root, math.MinInt64, math.MaxInt64)
}
func main() {

}
